<?php
if(!defined('ADMIN')){
	exit('Access Denied');
}

if($_POST['sub']!=''){

    $id=empty($_POST['id'])?0:(int)$_POST['id'];
	unset($_POST['id']);
	unset($_POST['sub']);

    if(trim($_POST['pointcode'])==""){
        jumpajax('300','配送点编码不能为空！','');
    }     
    if(trim($_POST['title'])==""){
        jumpajax('300','配送点名称不能为空！','');
    }   
        
    $data=array('pointcode'=>$_POST['pointcode'],
    'title'=>$_POST["title"],"address"=>$_POST["address"],
    "manage"=>$_POST["manage"],"tel"=>$_POST["tel"],
    "area_province"=>$_POST["province"],
    "area_city"=>$_POST["city"],
    "area_district"=>$_POST["district"],
    "worktime"=>$_POST["worktime"],
    "userid"=>$_SESSION['EZ_Admin']['id']    
    );
	
    $pwd=trim($_POST["adminpass"]);
    if(!empty($pwd)){
        $data["adminpass"]=md5(md5(EZKEY.$pwd).EZKEY); 
    }    
 	if($id==0){
        $data["addtime"]=time();
	    $id=$ezhand->insert("pointlist",$data);
		jumpajax('200','保存成功','','closeCurrent');
	}
	else{
	    $ezhand->update("pointlist",$data,'id="'.$id.'"');
		jumpajax('200','修改成功','','closeCurrent');
	}
}
else{
	$id=empty($_GET['id'])?0:(int)$_GET['id'];
	
    if($id==0){
	    $row=array();
		$role_menu_arr=array();
	}
	else{
	    $row=$ezhand->select("pointlist",'*','id="'.$id.'"');
	}
}
?>